state_space Derived Type

type, public :: state_space

Defines a state-space representation of a dynamic system. This implementation takes the form:

Where:

  • denotes time.

  • is the state vector.

  • is the input vector.

  • is the output vector.


Contents


Components

Type Visibility Attributes Name Initial
real(kind=real64), public, allocatable, dimension(:,:) :: A

The N-by-N dynamics matrix, where N is the number of state variables.

real(kind=real64), public, allocatable, dimension(:,:) :: B

The N-by-M input matrix, where M is the number of inputs.

real(kind=real64), public, allocatable, dimension(:,:) :: C

The P-by-N output matrix, where P is the number of outputs.

real(kind=real64), public, allocatable, dimension(:,:) :: D

The P-by-M feedthrough matrix.


Constructor

public interface state_space

  • private pure function state_space_init(m, b, k, n_out) result(rst)

    Initializes the state space model. For the second-order mechanical system the state satisfies

    The output matrix is initialized to one, and the feedthrough matrix is initialized to zero.

    Arguments

    Type IntentOptional Attributes Name
    real(kind=real64), intent(in), dimension(:,:) :: m

    The N-by-N mass matrix.

    real(kind=real64), intent(in), dimension(size(m, 1), size(m, 2)) :: b

    The N-by-N damping matrix.

    real(kind=real64), intent(in), dimension(size(m, 1), size(m, 2)) :: k

    The N-by-N stiffness matrix.

    integer(kind=int32), intent(in), optional :: n_out

    The number of outputs. The default is 1.

    Return Value type(state_space)

    The [[state_space]] model.

  • private pure function state_space_init_scalar(m, b, k) result(rst)

    Initializes the state space model. The scalar realization corresponds to

    The output matrix is initialized to one, and the feedthrough matrix is initialized to zero.

    Arguments

    Type IntentOptional Attributes Name
    real(kind=real64), intent(in) :: m

    The mass.

    real(kind=real64), intent(in) :: b

    The damping.

    real(kind=real64), intent(in) :: k

    The stiffness.

    Return Value type(state_space)

    The [[state_space]] model.

  • private pure function state_space_init_matrices(a, b, c, d) result(rst)

    Initializes the state space model. The stored realization uses the continuous-time equations

    Arguments

    Type IntentOptional Attributes Name
    real(kind=real64), intent(in), dimension(:,:) :: a

    The N-by-N dynamics matrix.

    real(kind=real64), intent(in), dimension(:,:) :: b

    The N-by-M input matrix.

    real(kind=real64), intent(in), dimension(:,:) :: c

    The P-by-N output matrix.

    real(kind=real64), intent(in), dimension(:,:) :: d

    The P-by-M feedthrough matrix.

    Return Value type(state_space)

    The resulting [[state_space]] object.

  • private pure function state_space_init_pid(kp, ki, kd, tau, a, b, c, d) result(rst)

    Initializes a state-space model that employs a closed-loop PID controller.

    The PID model is augmented into the plant model as follows.

    Where the augmented matrices are as follows.

    Arguments

    Type IntentOptional Attributes Name
    real(kind=real64), intent(in) :: kp

    The proportional gain term.

    real(kind=real64), intent(in) :: ki

    The integral gain term.

    real(kind=real64), intent(in) :: kd

    The derivative gain term.

    real(kind=real64), intent(in) :: tau

    The time constant of the first order derivative filter .

    real(kind=real64), intent(in), dimension(:,:) :: a

    The N-by-N dynamics matrix for the plant.

    real(kind=real64), intent(in), dimension(size(a, 1), 1) :: b

    The N-by-1 input matrix for the plant.

    real(kind=real64), intent(in), dimension(1, size(a, 1)) :: c

    The 1-by-N output matrix for the plant.

    real(kind=real64), intent(in), dimension(1, 1) :: d

    The 1-by-1 feedthrough matrix for the plant.

    Return Value type(state_space)

    The resulting [[state_space]] object.

  • private pure function state_space_init_pid_plant(kp, ki, kd, tau, plant) result(rst)

    Initializes a state-space model that employs a closed-loop PID controller.

    The PID model is augmented into the plant model as follows.

    Where the augmented matrices are as follows.

    Arguments

    Type IntentOptional Attributes Name
    real(kind=real64), intent(in) :: kp

    The proportional gain term.

    real(kind=real64), intent(in) :: ki

    The integral gain term.

    real(kind=real64), intent(in) :: kd

    The derivative gain term.

    real(kind=real64), intent(in) :: tau

    The time constant of the first order derivative filter .

    class(state_space), intent(in) :: plant

    The plant model.

    Return Value type(state_space)

    The resulting [[state_space]] object.


Type-Bound Procedures

procedure, public :: evaluate_derivatives => ss_eval_deriv

  • private pure function ss_eval_deriv(this, u, x) result(rst)

    Evaluates the state time derivative . This is the vector field evaluated at one state and input sample.

    Arguments

    Type IntentOptional Attributes Name
    class(state_space), intent(in) :: this

    The state_space object.

    real(kind=real64), intent(in), dimension(:) :: u

    The M-element input array.

    real(kind=real64), intent(in), dimension(:) :: x

    The N-element state array.

    Return Value real(kind=real64), allocatable, dimension(:)

    The N-element state time derivative vector.

procedure, public :: evaluate_output => ss_eval_output

  • private pure function ss_eval_output(this, u, x) result(rst)

    Evaluates the output vector . The term is the direct feedthrough contribution.

    Arguments

    Type IntentOptional Attributes Name
    class(state_space), intent(in) :: this

    The state_space object.

    real(kind=real64), intent(in), dimension(:) :: u

    The M-element input array.

    real(kind=real64), intent(in), dimension(:) :: x

    The N-element state array.

    Return Value real(kind=real64), allocatable, dimension(:)

    The P-element output array.

procedure, public :: poles => ss_poles

  • private pure function ss_poles(this) result(rst)

    Computes the poles of the state space model. The poles are the eigenvalues of and are the roots of

    Arguments

    Type IntentOptional Attributes Name
    class(state_space), intent(in) :: this

    The state_space object.

    Return Value complex(kind=real64), allocatable, dimension(:)

    The poles of the model.

generic, public :: transfer_function => ss_transfer_fcn, ss_transfer_fcn_omega, ss_transfer_fcn_array, ss_transfer_fcn_omega_array

  • private pure function ss_transfer_fcn(this, s) result(rst)

    Evaluates the transfer functions for the model at the parameter . In the Laplace domain,

    Arguments

    Type IntentOptional Attributes Name
    class(state_space), intent(in) :: this

    The state_space object.

    complex(kind=real64), intent(in) :: s

    The frequency at which to evaluate the transfer functions.

    Return Value complex(kind=real64), allocatable, dimension(:,:)

    The resulting transfer functions.

  • private pure function ss_transfer_fcn_omega(this, omega) result(rst)

    Evaluates the transfer functions for the model at frequency . This evaluates the transfer matrix on the imaginary axis, .

    Arguments

    Type IntentOptional Attributes Name
    class(state_space), intent(in) :: this

    The state_space object.

    real(kind=real64), intent(in) :: omega

    The frequency at which to evaluate the transfer functions.

    Return Value complex(kind=real64), allocatable, dimension(:,:)

    The resulting transfer functions.

  • private pure function ss_transfer_fcn_array(this, s) result(rst)

    Evaluates the transfer functions for the model at the frequencies given in the array .

    Arguments

    Type IntentOptional Attributes Name
    class(state_space), intent(in) :: this

    The state_space object.

    complex(kind=real64), intent(in), dimension(:) :: s

    The frequencies at which to evaluate the transfer functions.

    Return Value complex(kind=real64), allocatable, dimension(:,:,:)

    The resulting transfer functions, with each page of the array containing the transfer functions for a specific frequency.

  • private pure function ss_transfer_fcn_omega_array(this, omega) result(rst)

    Evaluates the transfer functions for the model at the frequencies given in the array .

    Arguments

    Type IntentOptional Attributes Name
    class(state_space), intent(in) :: this

    The state_space object.

    real(kind=real64), intent(in), dimension(:) :: omega

    The frequencies at which to evaluate the transfer functions.

    Return Value complex(kind=real64), allocatable, dimension(:,:,:)

    The resulting transfer functions, with each page of the array containing the transfer functions for a specific frequency.

procedure, public :: zeros => ss_zeros

  • private pure function ss_zeros(this) result(rst)

    Computes the zeros of the state space model. Transmission zeros are obtained from the generalized eigenproblem of the Rosenbrock system matrix

    Arguments

    Type IntentOptional Attributes Name
    class(state_space), intent(in) :: this

    The state_space object.

    Return Value complex(kind=real64), allocatable, dimension(:)

    The zeros of the model.